/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 hue_pixel.h

	$Header: /heroes4/hue_pixel.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( HUE_PIXEL_H_INCLUDED )
#define HUE_PIXEL_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "convert_16_bit.h"
#include "pixel_24.h"
#include "sized_int_types.h"

// ----------------------------------------------------------------
// pixel encoded as hue, saturation, brightness
// ----------------------------------------------------------------
#pragma pack( push, 1)

class t_hue_pixel
{
public:
	enum
	{
		k_red	  = 0,
		k_green	  = 256,
		k_blue	  = 2 * 256,
		k_max_hue = 3 * 256
	};

	// 0-255 - decrease brightness 257+ increase brightness
	void     adjust_brightness( int delta );
	// delta = 0-256 percentage to change color, 256 = become target hue
	void     adjust_hue( int target_hue, int delta );
	// 0 - 255 - decrease saturation 256 no change 257+ increase saturation
	void     adjust_saturation( int delta );
	t_uint16   get_color() const;
	t_pixel_24 get_pixel_24() const;
	void     set_color( t_uint16 color );
	void     set_color( int red, int green, int blue );
protected:
	t_uint8 m_brightness;
	t_int16 m_hue;
	t_uint8 m_saturation;
};


inline void t_hue_pixel::set_color( t_uint16 color )
{
	set_color( red_channel( color ), green_channel( color ), blue_channel( color ));
}

#pragma pack(pop)

#endif // HUE_PIXEL_H_INCLUDED